home *** CD-ROM | disk | FTP | other *** search
/ FishMarket 1.0 / FishMarket v1.0.iso / fishies / 426-450 / disk_450 / uucp / src / getty / passwd.c < prev    next >
C/C++ Source or Header  |  1992-05-06  |  2KB  |  95 lines

  1.  
  2. /*
  3.  *  PASSWD.C
  4.  *
  5.  *  $Header: Beta:src/uucp/src/getty/RCS/passwd.c,v 1.1 90/02/02 12:13:35 dillon Exp Locker: dillon $
  6.  *
  7.  *  (C) Copyright 1989-1990 by Matthew Dillon,  All Rights Reserved.
  8.  *
  9.  */
  10.  
  11. #include <exec/types.h>
  12. #include <libraries/dosextens.h>
  13. #include <stdio.h>
  14. #include <stdlib.h>
  15. #include <pwd.h>
  16. #include "protos.h"
  17.  
  18. #include "log.h"
  19.  
  20. #define BTOCP(bp,type)  ((type)((long)bp << 2))
  21.  
  22. extern long NullFH;
  23. extern char LoginBuf[];
  24. extern char PasswdBuf[];
  25. extern char *DeviceName;
  26. extern long DeviceUnit;
  27.  
  28. static struct passwd *Pas;
  29.  
  30. CheckLoginAndPassword()
  31. {
  32.     Pas = getpwnam(LoginBuf);
  33.  
  34.     if (Pas == NULL)
  35.     return(0);
  36.     if (strcmp(Pas->pw_passwd, "*") == 0)
  37.     return(1);
  38.     if (strcmp(PasswdBuf, Pas->pw_passwd) == 0)
  39.     return(1);
  40.     return(0);
  41. }
  42.  
  43. void
  44. RunPasswdEntry()
  45. {
  46.     static char buf[256];
  47.     static char redir[128];
  48.     char *arg0 = Pas->pw_shell_arg0;
  49.     struct Process *proc = (struct Process *)FindTask(NULL);
  50.     APTR oldConsoleTask = proc->pr_ConsoleTask;
  51.     BPTR oldDir;
  52.     BPTR DirLock;
  53.  
  54.     strcpy(redir, " ");
  55.  
  56.     if (*arg0 == '*') {
  57.     ++arg0;
  58.     sprintf(redir, " >UUSER:%s/%d/weT600 <UUSER:%s/%d/rcT600 ",
  59.         DeviceName,
  60.         DeviceUnit,
  61.         DeviceName,
  62.         DeviceUnit
  63.     );
  64.     } else {
  65.     if (LogToStdout == 0)
  66.         strcpy(redir, " >null: <null: ");
  67.     }
  68.     if (LogToStdout == 0)
  69.     proc->pr_ConsoleTask = (APTR)BTOCP(NullFH, struct FileHandle *)->fh_Port;
  70.  
  71.     sprintf(buf, "%s%s%s -Getty -DEVICE %s -UNIT %d",
  72.     arg0,
  73.     redir,
  74.     Pas->pw_shell_argn,
  75.     DeviceName,
  76.     DeviceUnit
  77.     );
  78.  
  79.     DirLock = (BPTR)Lock(Pas->pw_dir, SHARED_LOCK);
  80.     if (DirLock)
  81.     oldDir = (BPTR)CurrentDir(DirLock);
  82.  
  83.     ulog(1, "Execute %s\n", buf);
  84.  
  85.     Execute(buf, NullFH, NullFH);
  86.  
  87.     proc->pr_ConsoleTask = oldConsoleTask;
  88.  
  89.     if (DirLock)
  90.     UnLock(CurrentDir(oldDir));
  91.  
  92.     ulog(1, "ran\n");
  93. }
  94.  
  95.